"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _jsxRuntime = require("react/jsx-runtime");

var _antdV = require("antd-v4");

var _react = _interopRequireDefault(require("react"));

/**
 * 数字组件
 *
 * @param FieldImageProps {
 *     text: number;
 *     moneySymbol?: string; }
 */
var FieldImage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
  var text = _ref.text,
      type = _ref.mode,
      render = _ref.render,
      renderFormItem = _ref.renderFormItem,
      fieldProps = _ref.fieldProps,
      placeholder = _ref.placeholder,
      width = _ref.width;

  if (type === 'read') {
    var dom = (0, _jsxRuntime.jsx)(_antdV.Image, (0, _objectSpread2.default)({
      ref: ref,
      width: width || 32,
      src: text
    }, fieldProps));

    if (render) {
      return render(text, (0, _objectSpread2.default)({
        mode: type
      }, fieldProps), dom);
    }

    return dom;
  }

  if (type === 'edit' || type === 'update') {
    var _dom = (0, _jsxRuntime.jsx)(_antdV.Input, (0, _objectSpread2.default)({
      ref: ref,
      placeholder: placeholder
    }, fieldProps));

    if (renderFormItem) {
      return renderFormItem(text, (0, _objectSpread2.default)({
        mode: type
      }, fieldProps), _dom);
    }

    return _dom;
  }

  return null;
});

var _default = FieldImage;
exports.default = _default;